import request from './request.js'
//封装请求的api
const callApi = (url,method,data) => {
    return request({
        url: url,
        method: method,
        params: method === "GET" ? data : {},
        data: method === "POST" ? data : {},
    });
};
export const getApi = (url,data) => callApi(url,'GET',data)
export const postApi = (url,data) => callApi(url,'POST',data)

// 管理员界面
export const adminApi = {
    // 求职者信息管理
    getAllSeeker: data => postApi('/user/api/v1/user/info/get/all',data),
    searchSeekerById: data => getApi('/user/api/v1/user/info/get',data),
    searchSeekerByPhone: data => getApi('/user/api/v1/user/info/get_by_phone',data),
    getSeekerVitae: data => getApi('/user/api/v1/resume/get_by_userid',data),
    // 招聘者信息管理
    getAllRecruiter: data => postApi('/company/api/v1/company/hr/info/get/all',data),
    searchRecruiterById: data => getApi('/company/api/v1/company/hr/info/get',data),
    searchRecruiterByPhone: data => getApi('/company/api/v1/company/hr/info/get_by_phone',data),
    // 反馈信息管理
    getAllFeedback: data => postApi('/user/api/v1/feedback/get/all',data),
    searchFeedbackById: data => getApi('/user/api/v1/feedback/get',data),
    searchFeedbackByUserId: data => getApi('/user/api/v1/feedback/get_by_userid',data),
    // 岗位信息管理
    getAllJob: data => postApi('/company/api/v1/company/job/get_all',data),
    deleteJobById: data => postApi('/company/api/v1/company/job/delete',data),
    searchJobByJobName: data => postApi('/company/api/v1/company/job/get_job_by_mohu',data),
    // 岗位类型信息管理
    getAllJobType: data => postApi('/company/api/v1/job/type/get_all',data),
    searchJobTypeByName: data => postApi('/company/api/v1/job/type/get_by_job_type_name',data),
    deleteJobTypeById: data => postApi('/company/api/v1/job/type/delete',data),
    addJobType: data => postApi('/company/api/v1/job/type/insert',data),
    editJobType: data => postApi('/company/api/v1/job/type/update',data),
    // 技能类型信息管理
    getAllSkill: data => postApi('/company/api/v1/job/skill/get_all',data),
    searchSkillByName: data => postApi('/company/api/v1/job/skill/get_by_skill_name',data),
    searchSkillByJobId: data => postApi('/company/api/v1/job/skill/get_by_job_type_id',data),
    addSkill: data => postApi('/company/api/v1/job/skill/insert',data),
    editSkill: data => postApi('/company/api/v1/job/skill/update',data),
    deleteSkillById: data => postApi('/company/api/v1/job/skill/delete',data),
}

// 招聘者界面
export const recruiterApi = {
    // 登录 & 注册
    login: data => postApi('/company/api/v1/company/hr/login',data),
    register: data => postApi('/company/api/v1/company/hr/register',data),
    // 个人信息：1.通过ID修改   2.获取全部信息
    changeRecruiterById: data => postApi('/company/api/v1/company/hr/info/update',data),
    getRecruiterById: data => getApi('/company/api/v1/company/hr/info/get', data),
    // 职位类型相关：1.得到所有   2.根据名称模糊查询
    getAllJobType: data => postApi('/company/api/v1/job/type/get_all',data),
    searchJobTypeByName: data => postApi('/company/api/v1/job/type/get_by_job_type_name',data),
    // 技能类型相关：1.根据职位ID获得其相关技能
    getSkillsByJobTypeId: data => getApi('/company/api/v1/job/skill/get_by_job_type_id',data),
    // 职位相关：1.上传职位   2.修改职位   3.得到当前招聘者所有已发布职位 4.删除已发布职位
    addJob: data => postApi('/company/api/v1/company/job/insert',data),
    editJob: data => postApi('/company/api/v1/company/job/update',data),
    getAllJobByRecruiterId: data => postApi('/company/api/v1/company/job/get_by_hr_id',data),
    deleteJobById: data => postApi('/company/api/v1/company/job/delete',data),
    //分页获取所有简历信息
    getAllResume: data => postApi('/user/api/v1/resume/get/all',data),
    getSeekerMessage: data => getApi('/user/api/v1/user/info/get',data),
    getSeekerResume: data => getApi('/user/api/v1/resume/get_by_userid',data),
}

// 求职者界面
export const seekerApi = {
    // 登录 & 注册
    login: data => postApi('/user/api/v1/user/login',data),
    register: data => postApi('/user/api/v1/user/register',data),
    getJobType: data => getApi('/company/api/v1/job/type/get_all_and_skill',data),
    searchJob: data => postApi('/company/api/v1/company/job/get_job_by_mohu',data),
    getJobMessage: data => getApi('/company/api/v1/company/job/get',data),
    getSelfMessage: data => getApi('/user/api/v1/user/info/get',data),
    getSelfResume: data => getApi('/user/api/v1/resume/get_by_userid',data),
    insertResume: data => postApi('/user/api/v1/resume/insert',data),
    updateResume: data => postApi('/user/api/v1/resume/update',data),
    updateUser: data => postApi('/user/api/v1/user/info/update',data),
    getSomeJob: data => postApi('/company/api/v1/company/job/get_all',data),
    addFeedback: data => postApi('/user/api/v1/feedback/insert',data),
    // setFile: data => postApi('/user/api/v1/upload',{file:data}),
}
